using FluentValidation;
using Jupiter.Infrastructure.Domain;
using MediatR;
using Wips.AppService.Authorities.Users.ViewModels;

namespace Wips.AppService.Authorities.Users.Requests
{
    /// <summary>
    /// 创建用户请求类
    /// </summary>
    public class CreateUserRequest : UserViewModel, IRequest<string>, ITxRequest
    {
    
        /// <summary>
        /// 组织架构Ids
        /// </summary>
        public IList<string> OrganizationIds { get; set; } = new List<string>();

        /// <summary>
        /// 职位Ids
        /// </summary>
        public IList<string> PositionIds { get; set; } = new List<string>();

        /// <summary>
        /// 角色Ids
        /// </summary>
        public IList<string> RoleIds { get; set; } = new List<string>();


        /// <summary>
        /// 用户策略
        /// </summary>
        public IList<string> StrategyGroupId { get; set; } = new List<string>();


    }

    /// <summary>
    /// 
    /// </summary>
    public class CreateUserValidator : AbstractValidator<CreateUserRequest>
    {
        /// <summary>
        /// 
        /// </summary>
        public CreateUserValidator()
        {
            RuleFor(p => p.UserName)
                .Must(p => !string.IsNullOrEmpty(p))
                .WithMessage("用户名不能为空")
                .MaximumLength(32)
                .WithMessage("用户名最大支持32个字");
            RuleFor(p => p.PhoneNumber)
                .Must(p => !string.IsNullOrEmpty(p))
                .WithMessage("手机号不能为空")
                .MaximumLength(11)
                .WithMessage("手机号长度只能为11位");
        }
    }
}